package cn.study.disruptors;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

/**
 * @Author     ：跟大佳一起学架构
 * @Description：disruptor 例子
 * EventHandler:多个消费者 同一个消息可以被多个消费者消费
 * workderHandler:多个消费者 同一个消息只能被一个消费者消费
 */
public class OrderEventConsumer2 implements EventHandler<OrderEvent>, WorkHandler<OrderEvent> {

    /**
     * @description:EventHandlerd的实现
     * @return void
     */
    @Override
    public void onEvent(OrderEvent event, long sequence, boolean endOfBatch) throws Exception {

        System.out.println("EventHandler2 消费者"+ Thread.currentThread().getName()
                +"获取数据value:"+ event.getValue()+",name:"+event.getName());
    }

    /**
     * @description:WorkHandler的实现
     * @return void
     */
    @Override
    public void onEvent(OrderEvent event) throws Exception {
        System.out.println("WorkHandler2 消费者"+ Thread.currentThread().getName()
                +"获取数据value:"+ event.getValue()+",name:"+event.getName());
    }
}
